﻿@{
    ViewBag.Title = "订单管理";
    Layout = "~/Areas/Shared/_spListV1.cshtml";
    ViewBag.ListActionURL = Url.Action("OrderList", "OrderManage", new { area = "Hiner" });
    ViewBag.AddActionURL = Url.Action("AddOrder", "OrderManage", new { area = "Hiner" });
    ViewBag.DelActionURL = Url.Action("DelOrder", "OrderManage", new { area = "Hiner" });
    ViewBag.EditActionURL = Url.Action("EditOrder", "OrderManage", new { area = "Hiner" });
    ViewBag.ViewActionURL = Url.Action("ViewOrder", "OrderManage", new { area = "Hiner" });
    ViewBag.SelectActionURL = Url.Action("GetProductList", "OrderManage", new { area = "Hiner" });
    ViewBag.IdColumn = "OrderId";
    ViewBag.NameColumn = "OrderNo";
    ViewBag.ListSortName = "";
    ViewBag.ListSortOrder = "";
    ViewBag.AddWindowTitle = "添加订单";
    ViewBag.EditWindowTitle = "编辑订单";   
}
@model Kaiser.Modules.Hiner.Models.Order.SearchModels.OrderSearch
@section Script
{
    <script type="text/javascript">
        function QR(id,evt) {
            stopPropagation();
            $.messager.confirm('提示信息', '是否确认提交!', function(r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        url: "@Url.Action("OrderConfirm", "OrderManage", new {area = "Hiner"})",
                        data: "orderId=" + id,
                        success: function(result) {
                            result = $.parseJSON(result);
                            if (result.success) {
                                $.messager.alert("提示", "订单确认提交成功!", "info", function() {
                                    $('#grid').datagrid('reload');
                                });
                            } else {
                                $.messager.alert("错误", result.msg, "error");
                            }
                        }
                    });

                }

            });

        }

        function addSc() {
            var url = virpath + config.AddActionURL;
            dialog = parent.openWindow({
                title: '@ViewBag.AddWindowTitle',
                url: url,
                height: 600,
                width: 800,
                isIframe: true,
                maximizable:true,
                onClose: function() {

                },
                toolbar: [
                    {
                        text: '确认生成',
                        iconCls: "icon-save",
                        handler: function() {
                            dialog.find("iframe")[0].contentWindow.saveData(function() {
                                dialog.dialog("close");
                                grid.datagrid('reload');
                            });
                        }
                    },
                    '-',
                    {
                        text: '关闭',
                        iconCls: "icon-no",
                        handler: function() {
                            dialog.dialog("close");
                        }
                    }
                ]
            });
        }



        config.GridOption.toolbar = [{
                text: '新增',
                iconCls: 'icon-add',
                handler: addSc
            }, '-', {
                text: '修改',
                iconCls: 'icon-edit',
                handler: edit
            }, '-', {
                text: '删除',
                iconCls: 'icon-remove',
                handler: del
            }, '-', {
                text: '查找',
                iconCls: 'icon-search',
                handler: OpensearchWin
            }];
        config.GridOption.columns = [[
            { field: 'OrderNo', title: 'ORDER NO.', width: 60, sortable: true },
            { field: 'SupplierName', title: 'SupplierName', width: 60, sortable: true },
            { field: 'SupplierCode', title: 'SupplierCode', width: 60, sortable: true },
            { field: 'OrderDate', title: 'ORDER DATE', width: 60, sortable: true, formatter: Common.DateFormatter },
            { field: 'OrderDeliveryDate', title: 'DELIVERY DATE', width: 60, sortable: true, formatter: Common.DateFormatter },
            {
                field: 'PAYMENT',
                title: 'PAYMENT',
                width: 60,
                formatter: function(value, row) {
                    var arr = new Array();
                    if (row.OrderPayMentD != null) {
                        arr.push(row.OrderPayMentD + '%');
                    }
                    if (row.OrderPayMentB != null) {
                        arr.push(row.OrderPayMentB + '%');
                    }
                    return arr.join('+');
                }
            },
            {
                field: '操作',
                title: '操作',
                width: 60,
                formatter: function(value, row,rowIndex) {
                    var arr = new Array();
                    arr.push('<a href=# class="OpertaionButton" onclick=QR("' + row.OrderId + '")>确认</a>');

                    arr.push('<a href=# class="OpertaionButton"  onclick=EditItem("' + rowIndex + '")>编辑</a>');

                    arr.push('<a href=# class="OpertaionButton"  onclick=ViewItem("' + rowIndex + '")>查看</a>');
                    return arr.join('');
                }
            }
        ]];
        $('#OrderDate').datebox({
            required: false,
            onSelect: function(date) {
                $("#OrderDate").val(date);
            }
        });

        $('#SupplierId').combogrid({
            panelWidth: 500,
            url: '@Url.Action("GetSupplierList", "SupplierManage", new {area = "Hiner"})',
            idField: 'SupplierId',
            textField: 'SupplierName',
            mode: 'remote',
            fitColumns: true,
            columns: [[
                { field: 'SupplierCode', title: '供应商编码', width: 60 },
                { field: 'SupplierName', title: '供应商名称', width: 80 }
            ]]
        });

        function SearchOK() {

            searchWin.window('close');
            grid.datagrid({ url: config.ListActionURL });
        }


        $("#btnAdd").click(function() {
            var productWin = $('#SelectProcuct').window({
                href: '@Url.Action("GetSupplierList", "SupplierManage", new {area = "Hiner"})',
                title: '选择产品',
                closed: true,
                minimizable: false,
                collapsible: false,
                maximizable: false,
                cache: false,
                shadow: false
            });
            productWin.window('open');


        });
    </script>

}
<div style="display: none">
    <div id="Dlg-Edit" title="编辑" style="width: 700px; height: 550px;" buttons="#buttons">
        <div style="padding: 10px 20px 40px 40px;">
        </div>
    </div>
    <div id="search-window" title="搜索" style="width: 950px; height: 250px; padding: 10px 20px">
        <div>
            <form method="post">
                <table>
                    <tr>
                        <td class="itemtxt" style="text-align: right">HDE Code：
                        </td>
                        <td>
                            @Html.TextBoxFor(x => Model.ProductHDECode, new { style = "width:80px" })
                        </td>
                        <td style="text-align: right">Hiner Code：
                        </td>
                        <td>
                            @Html.TextBoxFor(x => Model.ProductHinerCode, new { style = "width:80px" })
                        </td>
                        <td style="text-align: right">OE Ref：
                        </td>
                        <td>
                            @Html.TextBoxFor(x => Model.ProductOERef, new { style = "width:80px" })
                        </td>
                        <td style="text-align: right">请选择供应商：
                        </td>
                        <td>
                            @Html.TextBoxFor(x => Model.SupplierCode, new { style = "width:80px" })

                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">价格范围：
                        </td>
                        <td>
                            @Html.TextBoxFor(x => Model.MinPrice, new { style = "width:30px" }) 到 @Html.TextBoxFor(x => Model.MaxPrice, new { style = "width:30px" })
                        </td>
                        <td style="text-align: right">请选择商品：
                        </td>
                        <td>
                            @Html.DropDownList("OERef.", new List<SelectListItem>(), new { style = "width:100px" })
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">订单时间范围：
                        </td>
                        <td>
                            @Html.TextBoxFor(x => Model.StartTime, new { style = "width:90px" })到 @Html.TextBoxFor(x => Model.EndTime, new { style = "width:90px" })
                        </td>
                        <td style="text-align: right">请输入订单编号：
                        </td>
                        <td>
                            @Html.TextBoxFor(m => Model.OrderNo, new { @style = "width: 200px;" })
                        </td>
                        <td style="text-align: right">请输入客户：
                        </td>
                        <td>
                            @Html.TextBoxFor(x => Model.OrderContacts, new { style = "width:80px" })
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">交货时间范围：
                        </td>
                        <td>
                            @Html.TextBoxFor(x => x.SumbitStartTime, new { style = "width:90px" })到 @Html.TextBoxFor(x => x.SumbitEndTime, new { style = "width:90px" })
                        </td>
                        <td style="text-align: right">订单状态：
                        </td>
                        <td>
                            @Html.DropDownList("OrderCode", new List<SelectListItem>(), new { style = "width:80px" })
                        </td>
                    </tr>
                </table>
            </form>
        </div>
        <div style="text-align: center; padding: 5px;">
            <a href="javascript:void(0)" onclick="SearchOK()" id="btn-search" icon="icon-ok">确定</a>
            <a href="javascript:void(0)" onclick="closeSearchWindow()" id="btn-search-cancel"
                icon="icon-cancel">取消</a>
        </div>
    </div>
    <div id="SelectProcuct" style="width: 950px; height: 250px; padding: 10px 20px">
        <table style="text-align: center">
            <tr>
                <td rowspan="2">No.
                </td>
                <td rowspan="2">Item
                </td>
                <td rowspan="2">HDE Code
                </td>
                <td rowspan="2">HINNER Code
                </td>
                <td rowspan="2">SUP.ITEM
                </td>
                <td rowspan="2">OE Ref.
                </td>
                <td rowspan="2">Image
                </td>
                <td rowspan="2">Car Model
                </td>
                <td rowspan="2">Description
                </td>
                <td colspan="4">Packing
                </td>
                <td rowspan="2">Note
                </td>
                <td>Price
                </td>
            </tr>
            <tr>
                <td colspan="2">Inner Package
                </td>
                <td colspan="2">Outer Package
                </td>
                <td>FOB Ningbo
                </td>
            </tr>

        </table>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var g = $('#SupplierCode').combobox({
            panelWidth: 500,
            url: '@Url.Action("GetSupplierList", "SupplierManage", new { area = "Hiner" })',
            valueField: 'SupplierCode',
            textField: 'SupplierName',
            mode: 'remote',
            multiple: true,
            onSelect: function () {


            },
            panelHeight: 'auto'
        });
    });
</script>
